using UnityEngine;

public class RewardUI : MonoBehaviour
{
	private GameObject uiobj;

	public UIEventListener boxbtn;

	public UIEventListener achievementbtn;

	public UIEventListener dailybtn;

	public UISprite[] selectflag;

	public GameObject[] itemobj;

	public UIEventListener closebtn;

	public AchievementUI achiui;

	public DailyUI dailyui;

	public BoxUI boxui;

	public UISprite achihint;

	public UISprite dailyhint;

	private int curshowitem;

	private void Start()
	{
		boxbtn.onClick = OnClickboxBtn;
		achievementbtn.onClick = OnClickachiBtn;
		dailybtn.onClick = OnClickdailyBtn;
		closebtn.onClick = OnClickcloseBtn;
	}

	public void init_ui_info(int showitem = 1)
	{
		if (showitem == 1)
		{
			if (achihint.enabled)
			{
				achihint.enabled = false;
			}
			show_select_item(1);
			achiui.enable();
		}
		else
		{
			show_select_item(0);
			boxui.enable();
		}
	}

	public bool GetHintinfo()
	{
		bool result = false;
		if (achiui.hintenable())
		{
			achihint.enabled = true;
			result = true;
		}
		if (dailyui.hintenable())
		{
			dailyhint.enabled = true;
			result = true;
		}
		return result;
	}

	public void OnClickboxBtn(GameObject btn)
	{
		if (curshowitem != 0)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			show_select_item(0);
			boxui.enable();
		}
	}

	public void OnClickachiBtn(GameObject btn)
	{
		if (curshowitem != 1)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			if (achihint.enabled)
			{
				achihint.enabled = false;
			}
			show_select_item(1);
			achiui.enable();
		}
	}

	public void OnClickdailyBtn(GameObject btn)
	{
		if (curshowitem == 2)
		{
			return;
		}
		if (Platform.GetServerTime() > 0 || Platform.GetServerTime() == -1)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			if (dailyhint.enabled)
			{
				dailyhint.enabled = false;
			}
			show_select_item(2);
			dailyui.enable();
		}
		else
		{
			Platform.ToastLong("Network failure, please check the network!");
		}
	}

	public void show_select_item(int indexnum)
	{
		curshowitem = indexnum;
		for (int i = 0; i < selectflag.Length; i++)
		{
			if (i == indexnum)
			{
				selectflag[i].enabled = true;
				NGUITools.SetActive(itemobj[i], state: true);
			}
			else
			{
				selectflag[i].enabled = false;
				NGUITools.SetActive(itemobj[i], state: false);
			}
		}
	}

	public void OnClickcloseBtn(GameObject btn)
	{
		MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
		MenuBackController.instance.BackFun();
	}

	public void enable(int shownum)
	{
		if (uiobj == null)
		{
			uiobj = base.gameObject;
		}
		NGUITools.SetActive(uiobj, state: true);
		curshowitem = -1;
		init_ui_info(shownum);
	}

	public void disable()
	{
		NGUITools.SetActive(uiobj, state: false);
	}
}
